package com.wxb.api.config;

import lombok.Data;
import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@Data
public class RedissonConfig {
    private String host = "192.168.112.128";

    private String port = "6379";

    private String password = "020416";

    @Bean
    public RedissonClient redissonClient(){
        // 1. Create config object
        Config config = new Config();
        String RedisAddress = String.format("redis://%s:%s",host,port);
        config.useSingleServer()
                .setAddress(RedisAddress)
                .setDatabase(4)
                .setPassword(password);
        return Redisson.create(config);
    }
}
